{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Modeling and Simulation in Python\n",
    "\n",
    "Chapter 9\n",
    "\n",
    "Copyright 2017 Allen Downey\n",
    "\n",
    "License: [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Configure Jupyter to display the assigned value after an assignment\n",
    "%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'\n",
    "\n",
    "# import everything from SymPy.\n",
    "from sympy import *\n",
    "\n",
    "# Set up Jupyter notebook to display math.\n",
    "init_printing() "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following displays SymPy expressions and provides the option of showing results in LaTeX format."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.printing import latex\n",
    "\n",
    "def show(expr, show_latex=False):\n",
    "    \"\"\"Display a SymPy expression.\n",
    "    \n",
    "    expr: SymPy expression\n",
    "    show_latex: boolean\n",
    "    \"\"\"\n",
    "    if show_latex:\n",
    "        print(latex(expr))\n",
    "    return expr"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Analysis with SymPy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Create a symbol for time."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAcAAAANCAYAAABlyXS1AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAhElEQVQYGV2QgRGAIAwDWydwBmbBDXQFl9QZ2ABXwUSNUrnL0fZpA1hrzXqZWYUSa38wA6B+NwxI+jUhKSr8YQbYBR0BCwuUnpjwgOrriST40bcfG/xwOMDgR3iNxTYyhLKewV2QXci/D2GDPIOfu/NySZBjeX0DYMzvKxrLN27QSmn8CWOLY8q7tsXYAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle t$"
      ],
      "text/plain": [
       "t"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t = symbols('t')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you combine symbols and numbers, you get symbolic expressions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACoAAAAQCAYAAABgIu2QAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABVElEQVRIDdWVi23CMBCGMcoAVUZghKoj0A1asQGM0BnaDVBX6AbQDaAbwApkg/T7I1+UWA5JEcXhpJNzr9yfeziuLMvJPdA0BOmcO8CzUH9Lmfwv8Al+sLyZPeiUA8eMKh+b+qHPjfiPoTHm50F9Iiu3ClWDlE8LKPIz/CPDrYniFOR8VV5ALzlUtJrC1s+xbGvriB4y0AucvkTlFj+iW3Me+Mo/t5C4f6EMMKrgFnAq9RxZ7R8dNVufbD6HVKW5TBqBryFBVP8dP/mHpE3NsS9CA/KRblXLErH1qiqgvFgJNJ+b3ggcSPgW8/Pjo+vt6rNtrX9SYhLUG+/Bx/Ak0RnQ1nxaZZIg6khqQNX66m9kY0B1k1z8HqfwtMiWScuxBqT+CBqBq89YK2uHQH7d3zlsi/qNboe8r4ACTNVMfn+CYwWOKDmMUcMlSj826khxSfy5mF82g1Zg3k0dlwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle t + 1$"
      ],
      "text/plain": [
       "t + 1"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr = t + 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The result is an `Add` object, which just represents the sum without trying to compute it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sympy.core.add.Add"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(expr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`subs` can be used to replace a symbol with a number, which allows the addition to proceed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAOCAYAAAAWo42rAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA0ElEQVQoFW2RARHCMAxFVw4BQwJIQEMlDAvMAWiYhHnAAUjgcDAN4KD816Yju5G7vyQ//5ImCymlBgshHOT6nJTPUW5U/ZZTEyKCbCqUdwJdzlljwouRXRUaj3Ai3ijAXsLHQO4NXr3dOB+rtB7tBcSyVpiEodYWHVVgqcFEo3z7V1hJ68qCbyGSByOVr023RYjt89Yc2w5e6N/3qZD3xq1xPJy/s9OEcg4rzM5GM+JO7CGOBpyhrR2vSham7tyRK/RMmZdRIYo8OXU+lUQPuC82XK6BdbIUdQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 3$"
      ],
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(t, 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`f` is a special class of symbol that represents a function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "f"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f = Function('f')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The type of `f` is `UndefinedFunction`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sympy.core.function.UndefinedFunction"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(f)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "SymPy understands that `f(t)` means `f` evaluated at `t`, but it doesn't try to evaluate it yet."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAUCAYAAADskT9PAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACEklEQVRIDaWWjVECMRCFD8YCGEugBNQOsAOwBOwAxxK0A2qwBOjAwQ6gBKQDfF9MbvKzCee4M0suu29fNrvJHd3lcun+o13XTaWrIRzCLcDH2OriAk6kG+naj0kgJBIw25jw2rPwH9Keq5UAwDcpWbPaIieXbS/tyQz/IfdrTtL7gDUT8CAWnfvneQgIo+wr6SbM81E+l3huZy5hY2v3XAFUgwNeBMXugs8R/7av32nmowrf2MZ6sORBxqPlwDYajTh4VK+KkZvq7cDlorizbEfxzG9ipwyU9U76JD1pziFkoWfGSKhQQQ6h7EspCaIzz3EQx7vmsRC/rJ0BGuV6pMACI99WWr168g1pIZvdFy1Qxq68chY7lC0ImFOYGOOjbF+GPTYRPykSkHEGSjtvEdwKQh9rUu1/FMD5mVoJNA9gRGA+qoKccCpEm66KlQAVaO0eUle+Cvs9dlWwb6FPKodTxaOVAASfOTqbUz4ILEn6r8U5kFQkF2znJAGfKSW8VgH8XFdLiHfvh9COynkifpdcMRk4PMKXVy+2eRx3O4lnLmFn7ppqbF1VviOzhEAG3tGDvm7CNV/FVnLBpliq5DYwpkdSvnwIFQjPztD4IdmXhr/lepXTvWUBsRNKRlbmxyNkno8+rvo5zvHM83Uw8Eqs/umwSILNkw1qWRTDZvukkzMQQH8ZIZNWD1vMBS5eHN8PTnR/TuT0iscAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle f{\\left(t \\right)}$"
      ],
      "text/plain": [
       "f(t)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f(t)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`diff` returns a `Derivative` object that represents the time derivative of `f`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADcAAAArCAYAAADczxCmAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEVUlEQVRoBdWZi1EcMQxA75grgEkJlEBCB6QDSDogHcCkgkzSAaGDJB1ABwl0AB0E6IC8t9jLfuz9kGNv0YzPu7IkS5Ysy7eLh4eHxdC2WCx2aee0O9rpUL5N0S2deCwsl0uZDuH9NZZ3SvqtsZNh2H7guRjLOzX9aONQ8D3tBq/dT63s2PmeY5yem73XXIhV12oQgjuMn9D00l+aRplUvtDmD7lMhuZ6yKy4E2l4NlOaTLYjbs59Mizx2DYG/KSdoPwNfQSfr8DNfr+pcNI48F9pGviDVoVXs99UOmfcB8Yuqh4K3nQPGpqvAlrGBSP02lXDAr1mNfMqMqW6towTGeB3fAj9R/rCYBbggKYXZw0t40Io6p1SeQw54t0jICaXPeji82wNTNaWITTP0Dp6T2PNkCYacWbMFw/PEB37zPWdOTsB2gMI1Otp0XkZfCtYBy0KuJ9PacehL8/RqvxAd17F9T3D4/FVypvUMJULChgBrrSIg5TS4C9ppaJNGsaum+O8u3CXkXZS48LkGmTmVRFDrqUDePd49r7IWLEwGV4X7tixluAUw7pwXUpV54Cu5ZXGuGFdeqgx5qLdiWtlSwZeEvYQ/rThEzOFJOKid9FlKyX47p0DOfurhPy1o5jIMHtLs/K55d2V14BP9g0w5FqZWGXBH9I8omy7Qc41cr7xXgX5D6cOS/dbsR9QKDk345Z3Rx3j2f0WeeSnXU4Wlqyyqy20vPKILn+luy3f2g/+E9AsDZtU8m9PZhyTWeHorT7F3kDmvslBdr9VGNyvOytW1FBZC6D4skNQbzLp4C2G0NVMqGcH3UxWPQr1zTdmXM/1eU15RUhlBL8Tj85laGsw701P6/2bKcNSxWKtqo45MKRULgW1/YZhJhc92QRx95MYF8LJkBriOWk8NlKgjOL8iyGK11Iy5b9IpmMY1opnIpMAYvvlBlrPrpYOjOmR4qig7zourEt3WwJSQv8Xx0TWe4MrfGg7y68ufeDVu8XidIYlrrcKOKfd0YqqAsZBAL23da8ggp6LzwWi58fF8P/S58BnmB517VqFOAaxx0XragIuu8JhzBByJZNFbpSf6uGRN3vlyfDU5uoNSyYo9gt97Y9Y3jvLIMYtgTovpCkFI875aINDWT7paeWCDDHOEGltcHC6frRHovJDehWlZRNHVYZ00ldxyf9QICqBfWPm+QNTrYIHb0j+Av/cvVHO8VIPq6pgFHalsh8+GDdEh147qqI38xzdyOwqPujDB3Sd+y3K3HRfHAV4xM1rqh764aNWBsE3S4jnnElDA4d++NDLZfE6S8tUytABDMda2uVdYx2s/UOVw286BFPzb4WQ1JBmAap3NL7pIav7Gj7IED0riGGpUs3rSO7DR22/YVju2rFxQ7fwzD1a6B2PgQJQ2APRy2X8e6364UMvD7l2FLI2+VMc4iGszlAkek9jNdpEI6788AGti2B1YnY1PHs/Uki3CfgH0U26dfMPWagAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{d}{d t} f{\\left(t \\right)}$"
      ],
      "text/plain": [
       "d       \n",
       "──(f(t))\n",
       "dt      "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfdt = diff(f(t), t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sympy.core.function.Derivative"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(dfdt)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We need a symbol for `alpha`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAAJCAYAAADpeqZqAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAv0lEQVQYGXWQAQ3CQAxF707BJTgYDggSwAEakIAFMhwMC+BgOCDBAThYmIPt/UtLLiRr0v32t//aLk7TFGqLMbbkg3Fr8EbPo+4JEpmwofDGdxWXyb94Yz3KD7VIgtYFjnA93pnoRJwTn8BKHaBJZ+V/9iHfGrdCPPpqWqH312uE142qC7NqiSnaU/7Cl0z1Z5lCkDwg1k1LNtJ392K5ieSK7510ZIujxZqk2zcFtaMR2ln2m0hNj/mPGgkHuMsMhpRwj4BD4poAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\alpha$"
      ],
      "text/plain": [
       "α"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alpha = symbols('alpha')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can write the differential equation for proportional growth."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIQAAAArCAYAAAC5DiCcAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGMElEQVR4Ae2cjXEVNxDHeR4XkI8OnA4AdwAdmFABpAOYVJBJOiB0AHRgUoGBDkwHwOvA+f1udBe9u9N9GFvnu2hnNKeTVrrVf1erleTn3dXV1b2ptNvt7sP7J+kh6Q1tf5vatvCtA4HdHIOoh4RhaEVPaPuuLivPbSBwNHcYGMOj0Ob93LaF/+4jMNsgGNJj0me8w/7uD69IOBeB6xiEHqJ4h7lIr4T/eEhOlocT6l+S9AZfSBqCgeUfpEIbRCBpECFWeMuYH7A8fHbslJ0HDIqHCEBs7dG7ZKD4Hxio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cLpkL6qGYoyql8Drts79+gFR58w3WKvuK+BJReduI58ljOWgz9t8QV5jBKnxFLXM1DkOvdgXytrnKBrKIphlOYNg0AIz+eYS3sGjawBMyk1bZ56HVUmeNdQxhkUwG1wysFJPA89J30jV6SKCTiL4/fuE+uZRa6/zU9oLxnXX9t9pO0vWKQLl4LkTmE2ZLYDh1rRzmkZZciaHOreHzthJp4axLLSxbfKCK+at89f9Vt1+6Sfyi+eimI26VQR0dmsQbu8aft6N8Cn6ryzOU2fwNPhHMDF/O09bDWnyMmN7+UmzjKj93SXfkX1xzBoFp4BASN13Z02mTLc8e+anvtNXTv8Gkcl7jbiNfPLHZf/H/PdiNrrLYF0zYv8AuJ67N0S57s1z+uuu9U1fJXN3EDiORUHJzkgVXG2HeLqXd59cHShR7/LhCZ18pqEraKoLrQ2BxkMEZbsTaP+4VyP4EU+gkVQEr/GDd/qj5wqhSXmsBIEj5UTBBnAaw9Qf9x4cIdtHoW0gUBkEQzFw1Cim/rhXr7H00TAiFLppBGqD6FzVBq9hnOBWrqFUecNQMqtG4CgoWO/QviTSC7gtbXsCb+AOykMfFhdaOQK1h3AYF62xPOW9MhIUHv9M7iB+sA4+PUmhDSBwFHYPeoFGqSjZQx63m/UfmcQ/7tWbTLmChq3Q2hCotp3B5b9G+NpLaCB7ksGmZf4boWrpgFfD8ZTSXYlLR+8VtHWF1ofAv7knh5o2DB4SAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{d}{d t} f{\\left(t \\right)} = \\alpha f{\\left(t \\right)}$"
      ],
      "text/plain": [
       "d                \n",
       "──(f(t)) = α⋅f(t)\n",
       "dt               "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eq1 = Eq(dfdt, alpha*f(t))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And use `dsolve` to solve it.  The result is the general solution."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "met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kXW+nAqCjaZAA5E30D8Jtoyr6Mcz+WyCuBgSORqnJm6Zgj9mAZO0uMwKjniquBm6puvsZ8jTj3IswqcToB26S9ZxsdgnO/thr8k5F78HmmCc4/CjkJc8mfmiNHLzpT6+Vo00GW37sAqTLMMSp7M3t1+FiQL+/ZOe+Q//cy4Sqfa440I6cUTZtvKPKHeBTvSpXOrRjKTJiVBcpDhmdkK+plqYEXGC9fY6CeB8j3w8WUPk/hmao0tbWm5NbmrISrOVJHvJqQomJRkpZZi/NxJIrN2rHyXMjFgNd1RhogXrzMnOJm3VcgB9KUXfpTYtx0IjK9UDbXDAFz+p0+E4J3ebZNZaR0X1Nq4PykfJZnpNfkOb/L2pqgTeDQTV3N2hP01aEFgNuneSl5Be/swOsJcW5RSbRLlrlOdvdE/xouv0e6oNfo9GflL7ZyhBLyebUfvHdBM9NU3puaJbZ6NsDna0T6d1u+mwb0MQDNzn6l8AjxU9howI3Zw31B95KjrdxzgpZdgr5qv+xIN/KYRSyPo4Byvhc9h7dZOloCstH8fDcIhNac24yfcuQmdN9BCUtHyh4WNNNiPLW+Tl/33Dpmrln7u4DZfONgZvmqoDLVj9xkzuDrj7g8r/ibqsUb+HXWibm3rWcvcYxoQw1iEjS/iF2n/p6FHvA6ceVvf7lEeoZMlmLkJ2COQXPInJVLchax7SoWKM7ICn0ShWOMSv/FqF5q+gLgNWg+bJ3Yt8rVjP8DnaL6agRL9pEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle f{\\left(t \\right)} = C_{1} e^{\\alpha t}$"
      ],
      "text/plain": [
       "           α⋅t\n",
       "f(t) = C₁⋅ℯ   "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solution_eq = dsolve(eq1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can tell it's a general solution because it contains an unspecified constant, `C1`.\n",
    "\n",
    "In this example, finding the particular solution is easy: we just replace `C1` with `p_0`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "C1, p_0 = symbols('C1 p_0')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG0AAAAYCAYAAADwF3MkAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFFUlEQVRoBe2ajXFUNxCAfR4KuIEOoANIKgjpwKQDoAM8riDjdOCkgozpAFJBAh3gDgB34HyfRquRdHp37+Kfc2zvjKzVarVa7Z90DxYXFxd7D3D7LbBYLD6h5Wv89Xnx4LT/hcOWaPkdXy3Udv/2q/ygIRZ4STsLSzxkWlhiBz0l75htv9KeuD2ZdGgfwPxTcGk67Zz2D+1Exks1hCj4zRw58B3IP4f3rvNghy+0l3FO8FPaO8fAcdDz2PvsIGiTDoPJOnpCe5f7FWNnng8hbE7PGpVbkTVn7V3hyfZs7AbtDU3nmFXFmZ4Z8E+x2TqnaVzT1+xwUfF0GA+amxRhQY+eOaOpmWdsMHwKnvvYc/7vtMaejHWW9JPaJoyfS29o9SBwmDSsjlKQeON5+QAjo9kg1uf55OyaFjjrDIZUCoJ2n3rO3mSOZwd0jsiytgVjK91p5tEXT4eZxsSkwUMgPCtZFHN5A0vrMKOgu3kTPfXau45rF1pJhGwPA5mjJwcWx0FLV1Smp7vuEcQR/AixPDF7hvyqcYdJHtaYpe/7tY5Zd46MM5qKfxzx3HHaK853GHYE10mOlzSd9zctbKfTjqCbcX/S9ponPxOWvBe0X2jfaMmgCHwLXiALeDag6ygV8kUp7nod+wXe3+gLZOVUtpFdGG4IQQ/1/JlmeVKXdB3QCwavXyHO02jmH2Qq44j2NS95Rm+WrAvyzDqjQ9BKiWSZOTp55zD3gTb5zGduTnlNr6XR/iMaMo1Ay8o2bfLOjT2UKw748LLklwcCuHuWVx640S4t9SGj7pkzCJqrg7FB3Dzj6zXb4iOHuYGneD4ljLnmcD0f85P3WfDCo2PNwBUdborG/p41OYneYEgXfuzP2MBimJwqXgwPrv49f7qrnatkSNMek/YM3rn9I4T1YJlQ08/9RDV+DL6uZBhtUZOrZQ1qqdBou4RvnDP09Ny/dspY1vZyufPLRCnlroN+6hx42OKPvP4xdLNRcO6w4knEy/wZOW3tI2TTZvmAOsMSeqshDInOBpnQP4p0ZDjEM3nP1+BcHaBm33vk/l4zXTU+cpqKrssydVD5pcgAfpCG4sUAXTTGErN19sWMDO+SMG7I2NSfoYcPo03gQ0TecFBkl/vpgKgIZT4L1A6eo4bZZ6oXbYOPnKbR+zLRy1SxXtng0QDF6Rjb6JO/0DKjhuiNkKdWOwzafExd5bgUReeUIMuSfEGrn/uG03RSD8uKMOkw7ODDrnlBV+u2QvdrbjOCsa03cM0m7rw/DUbg+qR8ludnrJE81/eGGsm7CZrVJRxjljk2s3+qs49xH6j92AdHUw20AU163J2gl4M+01ZK24R47ysVGYGHPUFRX1uWyanocq/X8uwS0DOMfAwejwcfIC/QPTIn+jqrVLsJcM+KDJ2ubXyNJoBeHjBBu1SPQA2bGoI0ePldEvRRD1/zW2TEM0VjrYfd6XM/dEMPz7xRF3lo5dOT6wH/lE9OIfO6+32i4oDmD0vBqAs8Edb88bD/9Z45Yu1Upq7Z8lqmPPOcMq2+5VGj3Rj7Ujy/Fq3WCPX/HBhBpr8K/YUSU3cV0y2guGXyLWuifLQMgxFrzLKt9hmIuRJS1sV/DnnFGTbeOfBbPp/kzXf6Cc67R2WMpObfvjhIKZ0jHH4dMKucxnr5t90n1l5ljw5migFrifP+mfxsd5X7XoWs5oMxim8NRJ+vLmv9xh+U8BogH+GdnZlbK3QPFvwLuEHX/wzxq6MAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle f{\\left(t \\right)} = p_{0} e^{\\alpha t}$"
      ],
      "text/plain": [
       "           α⋅t\n",
       "f(t) = p₀⋅ℯ   "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particular = solution_eq.subs(C1, p_0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the next example, we have to work a little harder to find the particular solution."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Solving the quadratic growth equation \n",
    "\n",
    "We'll use the (r, K) parameterization, so we'll need two more symbols:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "r, K = symbols('r K')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can write the differential equation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPMAAAAyCAYAAACJQu0uAAAACXBIWXMAAA7EAAAOxAGVKw4bAAANVElEQVR4Ae2dgZHVNhCGczcUQOggoQMCFSTpAJIKgA6SoYJM0gGhAhI6ACogoQNIBRzXAfk/oX0j60m27GfL1sOa8dmWVtLuale7K8n3Lj59+vTVntrkwMXFxe/C/KXG8FWbFKyHtXh3U70/E+8erIfFvD1fztvc3lotDnhF/upLUGTR+q2uRyW8Fdx94IdgxbdrwTwV7L9DsK2Uj1JmEX5H10tdH3U9bYXIc8NTvP9FNH0rgfy1ZdpEx03kCHr8/UgJgRGNT0XrnyW0Cu6F4H5XvaO24vqCxaM5G4Uepcwi/q2uH8UAGPwyZs7+vjwHJKT31csTjcM5uIfPRAsW8r0uLO8dXXF6rYzHcaa9ix/vEor7UOV/G0zfXXxkkrhSG4QsTadRygylIvoHT/Eep1UeevGeSRQFaF6RPS1MTBgFZOlHKRZW9ZAEg4L/o3yU/SipnPp4KJ1yvTNBvFI5HkxJgp+PBG+yXVJnczAXInwUUiKYGey+6t0eVXEHPpkD4j2C/168z1qqkzup1IBoQRH/Fi0XuS4F805lKHlHWQ1e5YR6d1X+neXZXWVMfP+p7GvL67t7fFgQK4Lva2utstGWWYgye+1WufK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9LeSuOG9KUCzIHs1ZqA48p3CJcCY1q3bLQhSwetjK9UuF2899lKF86MaGwVtFUuvTKiZsdu81uhhQjXewSUHWX5zDftxGA7I9zccDzGQtxTltuSfZIjswqpwxFFessHIjRSYfJ5PPr9v+aZQbTNxG6xGlOwUVg+NtSnXiZMsFhqfe0HAcQ5CZ/M3gkSyxejg2IGQ8mNWQR47NUwpV/oUmUtYqm0qVHGuYdFFLMYs8Wd8ZihvC3pWCky/dMzX25JLA9zcEBjRFWAuGqFTPOgfaUNtzagOiNvURry1zfRfjgDRPyPfUoseG5yt3tM3ulfCYMzDqj3AgPFoE89vzcbClYlB6muljOC5pe97QkB7ygwfOz2nP2soecEb5ZPMwq8hvJli2AsWaA+8s+sxkd5PHkf6mrNg5JfXCmgr3lavvZh85neOgcGpmhvb2JBTnQurAtyJqTmxZv8QowaN9ImTFkzaVdmRsaMgkcVgnr8b0ELueKNkTRNlAVX3Gt/9PFSUfngW4Ds3FY7Mo8jl+rQ3sLwhnl26sjcyYIiKeEL1fiaZPutQ3DpT3s9zY4IIEjnuRIrVuzaAPr7WIpPrLYyz9NbFqR4fCuzNuVsyxmJngSRNsTzcLuBXkOiH/sa7OIZltieeAGSnZlbmCQUihKADlEctsLZApkz+vhgPhGnIw1/r4HrKmi/wGGmZ5mwSkcQQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{d}{d t} f{\\left(t \\right)} = r \\left(1 - \\frac{f{\\left(t \\right)}}{K}\\right) f{\\left(t \\right)}$"
      ],
      "text/plain": [
       "d            ⎛    f(t)⎞     \n",
       "──(f(t)) = r⋅⎜1 - ────⎟⋅f(t)\n",
       "dt           ⎝     K  ⎠     "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eq2 = Eq(diff(f(t), t), r * f(t) * (1 - f(t)/K))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And solve it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAK4AAAAwCAYAAACIYEHdAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAKkUlEQVR4Ae2di5XVNhCGs5wtIFACdACkg6QDQiqAdABnK+BAB0kqgKQDSAU8OoBUkGU7IN+nSMayJb/27r13E805WtvSzEga/xqNZF/vyZcvX75pdH0scHJy8pjW/ki6IJ175B4+Jf8J539w/onjJMH7PQxPSR7fkH5B7g+OgSh/z8ldkmU/UmZdx0U06puWjt8GoOY2SUA96d8vrr8lvSZ97ufPncPvABjJkGc9v3uc07GrcuoKA2WNvlOEGh25BfCAgukj6Qdurl6wI64vKBdoa+kHBN71hdDzgGsBq0efJetdyltThg4H3l30fKjxlPJvlDJb3tFZQI/6gpubgbbXSgEozxoyTOhkAJChhmHHixVKBN1lyXbMhjfDShpwhxZZeO2N1uOQvsT03uuheIHH2HExIS+g9LjPJoS88b9OlGdF6BRwpg+ekwSwoK0NjEx+6QV6H5O0kccHpGSz25ybfkHXc+v2nLTcNjS2xbiXsAFGd3X7vmZHypx+BcammBE5Q4TXNf21fGQcRN+Wysm3TbZbbydwjDG31DEpg07jaOsIddkWyP58n9rFuXU/SNdLj6cINdpoATyEN0UqeirKvXHn3Azjya2kt+1W/HNKotf6Cb7UtpLIdzHTweSOhLyvleV6VaxZUm4eumz3K5I2eIPeYCOOd7juk152dZ0NuH0Trj9PgOxiRVVw05yGz0huM62O39TRo0n5WNdD6gmhAkdBYAigV62RQP21J/MGfuuxzcWFGeVhp2Gg0Olej9kn+6zu0G7KHSSZfRIzZYLWEGWyj4k/OyLUQoWNNsCQ3jRM+NWGXHsznvfzLnOOLuPA6pRcq4t8p+RaqOCcnU3PXpPMXxzSwFttV+ozPJ9JevIRzsg3fndngkOIuRfX3RZnmmw7ZdMcHsRp8WduhJv7iwgZF0fPSS5cTC5SnGYDoetnTvRs6u6I6yBHhsBeTMjZZimbnq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EWA07MeSs/nroGreUHcvWFGnuc7+3oiutyd0ctJ2S4Ldbn/fUHaughWZ0bUFcIFdGd19Zi2f0Gxp+SqT0+vuoLroj+uXJ1C3XQPW0ExT9BkOyCU36HMT4PKf04SXH+TnlHm+WJSD8x6VsknbnrsVH/K938oGEJ0A+hf9k1/Be7Ulqd9PaM+Pe/LTTXsQaj4Pu4e6j26KrhRglCPK1CdIiVB+GotGIPk4A/6DRX8ntgqYA/UzF5Sj6HC5D76rJIVDNSnrf5cISLroidy6DZUcCDdHNqteVzN+C/p3fwI3ar91yRcO2J8wwAHhJ5OLy2wSo/AayqOOj8Cqvb4/8ra3oCbm3bnT4u4scaSpjVPv/JWrbvaRTixrsYDcLfF2VejV0GLlzTeuxbEQKn241p0YGEjG3C/GspYyim9IwDbPkLXWeMgJ2mtMaq8Lc56JometX2ErmeTQ5xyH3Qit0g6EsFrqPWO5CsJYQ3SgIs1Gl0/C/wDJG6RQ5oP+TQAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle f{\\left(t \\right)} = \\frac{K e^{C_{1} K + r t}}{e^{C_{1} K + r t} - 1}$"
      ],
      "text/plain": [
       "           C₁⋅K + r⋅t \n",
       "        K⋅ℯ           \n",
       "f(t) = ───────────────\n",
       "        C₁⋅K + r⋅t    \n",
       "       ℯ           - 1"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solution_eq = dsolve(eq2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The result, `solution_eq`, contains `rhs`, which is the right-hand side of the solution."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG0AAAAwCAYAAAAb6PR/AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAHdUlEQVR4Ae2c23HcNhSGJc0W4KgEuQM7ec+D3IGSVBC5A2lUgUfuQHIFsd2B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wr9WB/+r+lqdzHyjNeaDG3yEbKWTX2Q2Wa25wXnrQmBxNO+pjSB0mZRhxF6vJI/73l8ZnMnB7oWxlMQBZBpOwlk0HPC+1hGOsvWP+JNpLzfBq8U6upScIeUxonnKheRhq78reZAYg/5wF38yjUD6KbTdygskqj9qYaOHRSWU0kcwuDLrjbo3J4i9IV96G25tMKchsHOzf6oWPqKIquYU8lN59tBvooT2iJh++cirkHWYsoP6PoumIMnuYxYbGKikOY26SRlrmpy1/CCiscZkE3u+iBRovlz7jFp+EBGZZ5oL+YIkOlYnkXAct5hP6vzHBLeN0wRY2kws8D/MYSysTHURBgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{K e^{C_{1} K + r t}}{e^{C_{1} K + r t} - 1}$"
      ],
      "text/plain": [
       "    C₁⋅K + r⋅t \n",
       " K⋅ℯ           \n",
       "───────────────\n",
       " C₁⋅K + r⋅t    \n",
       "ℯ           - 1"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "general = solution_eq.rhs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can evaluate the right-hand side at $t=0$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFIAAAAwCAYAAACCEC3KAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFkklEQVRoBe2ajXHUMBCF75gUAJQQOkigA+ggDBUQOkiGCpikg6QEkg4CFUDSQegAch2E9ylaj2RbPsun+3HGmtFJWu2uVk+rtc/S7PHxcTaWPJvNjpVvlK+UL5TPsF3pRHm/7zzE+14ZPQhTHoWyat8GfS/DvlR9FCBqUvt+cifhRER7qQwQDyG9T10yLEpDTjTGYqF6Lwzj7Ulgp9N8Pmdi98ofZPCP0Fi1F+pn0kPSBwn9DgWl60htAPwY0vvUX/Rh2jIPHndeBzGwCTDgyU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yMuh4S4bEDRxSvlbMve7YaVICI7X4OPEy5pNWcS87KSgFe07gJkdIhXo4lGJwz7GgFQxnPg27nhSoBlnbnsW6oY1N1bPS2RfPJ9cjG2YuUVsmvHAO5pMndKZ+q8c+TUgXAXYrXndmotNPIrgO0lK6t0PfCUf32w/i/ns7hFB5oADJBO/zyLFHx1QMXEXs00PmtxscCEBK4G2Tj11h2qCkj3XukTMIreK3pvNTkeaIHgWjEDLZwJWt6KZWSd3HUB4gwNWRFIyQMuh0Wjl+yLntat7aBCBC9LzWJF9B2+nZYSfBCXSkg3UcLnkhiwCPZTvZEWqj+XUooV0rSj0celtC1zBAfnn4u46v1f5ZtqQsPEav045FcZHgVzsdiJO9G1+ooekCvQdm2LBD/hs7U5uLVWm9S+MkdaryNJgOSQYsHdE2KVSZXtzEY6Dkme/1JgigvGuWlpk0vlgHJnmcLVkkAjvpSUzWR8hV7hkSaqy/k3vOezaWmaJYFGsIHZ3utjMMBJiHrtzI3lC8rIEWY0goI/AcNYq0O1jKVHwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{K e^{C_{1} K}}{e^{C_{1} K} - 1}$"
      ],
      "text/plain": [
       "    C₁⋅K \n",
       " K⋅ℯ     \n",
       "─────────\n",
       " C₁⋅K    \n",
       "ℯ     - 1"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "at_0 = general.subs(t, 0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we want to find the value of `C1` that makes `f(0) = p_0`.\n",
    "\n",
    "So we'll create the equation `at_0 = p_0` and solve for `C1`.  Because this is just an algebraic identity, not a differential equation, we use `solve`, not `dsolve`.\n",
    "\n",
    "The result from `solve` is a list of solutions.  In this case, [we have reason to expect only one solution](https://en.wikipedia.org/wiki/Picard%E2%80%93Lindel%C3%B6f_theorem), but we still get a list, so we have to use the bracket operator, `[0]`, to select the first one."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(list, 1)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solutions = solve(Eq(at_0, p_0), C1)\n",
    "type(solutions), len(solutions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHkAAAA8CAYAAABCbxWWAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAIhElEQVR4Ae2djVUWORSGhUMBuFvBYgf+VCB2gEsFQgd4rMCDHaAV7LIdiBWgdiBbgUgH7PuE3Gwy//DNMCHf3HPi5G+Sm/vm3txk8uHG9fX1o9xpY2PjAB7F68fceb0P/iSPbfXzSfJ4PaS/rSGV5qyjAR2p/30N6NmcfOTUt2RxJbmcKHwbIpcNVcqJ/4QXDWJXGacKfzCwpHBJPPIK8EKy6dTobEHWADBJ/yq81CC+L5g2SwBtVsmJZNS6lOUMMhrMOtw5S5uHvj65AnlHowXoVmuXJchi/Kln/IlAvlgfyO42UsmrUyFyBZmZebFo8TDQI6V4LJnVfJfsQPbm54eGt2jxMIxdLckNxfhLIH+ovpYjyCdi8rmYzXbLJIGyb4c/BAvhJL5QeC++Z3ESPU/H6v8xDMWU4z75TzH4PmYy0zjr4GeFZwArIeNHkPdEge0NwL9TcFZJTyZAzZQqfyw6U0Pb6ndX/RBPyJhjVjIT8GhnCeofT5GN+9O5eOjr1/MIgBzSnFp9n6/kjeyUZgJsk+ZJ2sqmeqqPXwo1DLfUIbPwjQrZkyLkOYnDDybYLCZvyMDFm/P2JTPM83n0DsoSaypLjkvzVP3nUd2pomiwk2HcwSYJz8zXuGCmOOvcQ9kyIczYLO4r/TdyE6BNynKpfCbClMSkq/WR25qM4LIH2YOICXaa6sFDuHM7i2ZldsziiKdHuYGMBsTaAY85EoCypOwJYPjD2cIBM/N8oXwmQUy/KTH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BSyNpktI/DRUAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\log{\\left(- \\frac{p_{0}}{K - p_{0}} \\right)}}{K}$"
      ],
      "text/plain": [
       "   ⎛ -p₀  ⎞\n",
       "log⎜──────⎟\n",
       "   ⎝K - p₀⎠\n",
       "───────────\n",
       "     K     "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "value_of_C1 = solutions[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now in the general solution, we want to replace `C1` with the value of `C1` we just figured out."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOUAAABDCAYAAABjjMLlAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAPaklEQVR4Ae2d+5EVtxKH2a0NgEcEF2eA4f9bdXEGGCIwZAC1EbhwBr5EYHAGmAgWyMDcCFg2A+7v01HLmjma15557umu0ozeanWr1S1pHiffv3+/5eAUGJsCJycnn1TnLxpfn8eu+6bXd+JCedNZPH//JJC31eo3ja2T+Vvffoun2++C92CFFHgsnL6sEK9NoORCuSCbpFFeyr2T+x7dJ8J1lAp5HtTzzBkWPs8jTtyfyFk//i3/78LltdwVfrlFcZ2TLmO1dTZWRV7PcArIvPuNUhq4LOw/K/xjQy1/KB6T8IXyrEUDIXzv5X6iH+rD3/Kfyf9CftaTv8r/p+4OAyngQjmQYGNn1wDG1AP+2t2qV6U/V8ylBvhP1ZRlQsLnvlp+KwdefwmvgLfuP2QYoR19gycjyBCvC+UQak2T14QNrZNAgx/NeC73uwb8WrTjLcNF+D0SbhWcQV7xCOSV5SPOYRgFfE05jF5T5A6aUoM4aco4sM8V92rFgxu8E84ZYVI8E4scmtVhAAVcUw4g1kRZK6aeBjFm4Y8Sxhdd7SkvAoCmpQ7yo12JA9BknBNehdCAC8Kk7Gjpr7EYp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G/cn7aicLMb2agZlQfzPaxD5UdAN7dfEfl3rn6mtXFpRLhQlqiy4jgxlrXXjfq5j/rE+pB3VRsf3o+CyLEMeTlS4AwzaFL5NwGRd/SzdUnnQrkJdv6DpBjLZhG7sLM+SPAPBuP61B9MYPqEQB7yJYdxERu5NvUTs7yXleNCOTLx56hODMaU45zu6B91m4Peh7YhfrEm53iJdXLnOtg3eg6l+DLlOSPknxu2Q7oMFt5qJwXEI9a/TKJYAZ0CSYWuKaHCBiHOvjB7888Yb5D8vVEWn+ARm1Kt68i8QhfKnBob80fB5NGzylnixrpxY9GNWpJ3Ufs8P53o8H8YJ+3ekIhQcQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle - \\frac{K p_{0} e^{r t}}{\\left(K - p_{0}\\right) \\left(- \\frac{p_{0} e^{r t}}{K - p_{0}} - 1\\right)}$"
      ],
      "text/plain": [
       "             r⋅t        \n",
       "      -K⋅p₀⋅ℯ           \n",
       "────────────────────────\n",
       "         ⎛      r⋅t    ⎞\n",
       "         ⎜  p₀⋅ℯ       ⎟\n",
       "(K - p₀)⋅⎜- ─────── - 1⎟\n",
       "         ⎝   K - p₀    ⎠"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particular = general.subs(C1, value_of_C1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The result is complicated, but SymPy provides a method that tries to simplify it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIcAAAAyCAYAAAB24MjMAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAHvElEQVR4Ae2c/3UUNxDHc34uAJwOnA6A/J/3Ah0YUkFMB+a5gjzTAekghg6ACsB0AB0ErgPn+5E1iqTV3q3Pe3fateY9WdLo12hmNBrpVl5cX1//1GA/HFgsFlca+U/J4Mt+KFg96qIpx2oG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ihE+XLFihWvWoUfiSKIembPcbwQQbG7RqwMG8IQ+Xrdm2Y5Q5p/WFcChDfORGGXLAqsTQqxhaNGxRU4JR+JIrB2Ye89x3gYNjCtRiPfCNzDrYHQMWLn8gnVuJPM+cmJtZTvL0N9UH0qPw5RAGiA8w9ImCY7RwGz9cVh87AdFoglz1QNqsQW4lyCcLQAtiFg+kR+XLPp0sCWhjh1RtUei1dy/UUXC/gdhcle84sVY29VhzG40v+baivncK+AvuuLzBqKV9tdQN20U4EmtloZBzfgM7Gl869xwl7taGk4DZFjiqJvcbfXSqPg7l7N/Ajs6XqZlRCZmVz1bB1sAF16R+8t8Wv8WH0fnyH5FIAnuyUyVKAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{K p_{0} e^{r t}}{K + p_{0} e^{r t} - p_{0}}$"
      ],
      "text/plain": [
       "         r⋅t    \n",
       "   K⋅p₀⋅ℯ       \n",
       "────────────────\n",
       "        r⋅t     \n",
       "K + p₀⋅ℯ    - p₀"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particular = simplify(particular)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Often simplicity is in the eye of the beholder, but that's about as simple as this expression gets.\n",
    "\n",
    "Just to double-check, we can evaluate it at `t=0` and confirm that we get `p_0`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABMAAAANCAYAAABLjFUnAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABPUlEQVQoFZ2T/VECQQzFXccCbrAD7ADGCjg7OOxA7QBquBJsQegAW5AOoASkg/P9cgkTbjz/MDPvsvnY7Et2r3Rdd4OUUmqpJ2EmvAmVgA95FF6UezZr7EMxL9i63ij3IDQ5JnuX7JXsVjB98XuBaWyW/hI2keDxV/m0tC5Y28FuN5EfrCoCHmTHhZX7YIGf1mFdR37aU90qQBGbhc8N1yefJMwx5kUXpxRjSay2YinABRyjOH4dABsu4kOgEBKFe6svPhkWY9OQ1bNvXsdO6SEzQn2bKYl24nRYYTOvRWYreyJkMfsuPGlerdZcOfIgzFXoaJZG4JrWs2Dv7QaVTAAGB9Z/gRxh/DYVRH6bVx+5/r7LXIZLXfDOtiJwLrCQA5rfJMneRuKY9jHce5w3yu9nQmWo0yuvf8UB/8EP2Yb1Q0L/7KAAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle p_{0}$"
      ],
      "text/plain": [
       "p₀"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particular.subs(t, 0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This solution is called the [logistic function](https://en.wikipedia.org/wiki/Population_growth#Logistic_equation).\n",
    "\n",
    "In some places you'll see it written in a different form:\n",
    "\n",
    "$f(t) = \\frac{K}{1 + A e^{-rt}}$\n",
    "\n",
    "where $A = (K - p_0) / p_0$.\n",
    "\n",
    "We can use SymPy to confirm that these two forms are equivalent.  First we represent the alternative version of the logistic function:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEEAAAAuCAYAAAB3VXTKAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEEUlEQVRoBe2agVUUMRCG93wU4JMOzg7wWYHQwaEViB3AswToADtQ6QA7QOgAOgDt4Py/bCZms7seB5u9W1/mvVySmcnuzGQyyWW2Wi6XVVyqqjpW+a6y9OWafsxDG5yn04FnL+WZSr9hgFhor+B1jIvboi9ULlXmMX6K7R0p0YLZbLbvkT9aRCFEP1L1IIUPuuhTw3UaQUqYcsx0ACn/Up3PKucywF0gTLwxw31TkLK2xmdGE25P7Q/iPzHc/1L3eQIK35iS3v3fyACfDLfpWjKxZPFYZEUuvNSW8Vu1P0re36pX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d+TzCH7h0Kgisk3QWAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{K - p_{0}}{p_{0}}$"
      ],
      "text/plain": [
       "K - p₀\n",
       "──────\n",
       "  p₀  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A = (K - p_0) / p_0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIQAAAA5CAYAAAD3EIMMAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAHTUlEQVR4Ae2diVEcORRADUUALkJgM7BNBpABXiJYNgO7iMCFM8AbwS5kgDcCjgxMBsZkwL6nknrV0z3MTM/VM+pfJSR9Xf/Sl1qtHnZeXl7elAY7Ozuf4PmQcBJ5fyB+RBYfYz5E1Lsikdf5gzrW3VrYKdEgkjZRuLPhARm8T7g8plxj+NNAnce8bFvTe9vK2CS+UPZRrPO9rS7lZ+CfMITjtvJtxRVrECg0KfomVy6G8Jb8OeGyFK9Q4x+m83wxaRR/D7Pv4H8nMQ3uHelTcJ8TrrS4ZA+h8qsNYlwi3mMM7hmKhSINAuXX9g/kfeq4IBSxcXzN2ndfK9zisrR/+Kkx4BW+wus3wgH59Ji5xeyPZ61Ug0ge4jkagxLSQwhuKIuFIs8h8ALupL9jDMlTBAMA7xOHxuJeotpfhMJC/hTnIVB68g61x82o7+K9RHEGgeKTV2gcSOEVxLmxPMFwPI8oDko0iLBpfGVJuIxWUOReogiDcLYTLgkeRh2ocNJXBB83K4j5dA7xifwNIdSvKm15oshN5ZbrdC72ivAQc0mosMaDQRSm8EnsDgYxSUKFlQ8GUZjCJ7E7GMQkCRVWPhhEYQqfxO5gEJMkVFi5t4XKvDJVmKKnZXc4mJpWUoXUG5aMQhQ9LZsbZxCb/G4B2r3H2WvYKINAoBe8pazdewR3RPAl1EuMa1fgwN1nZet+pe0VvXQfY22GA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tum9x8BAQ2GtAaF+ZPQq7sSteIeGu+5OWB2f1ObS6d9CDNGY5ZU4UjauXsBEGESWnS20eta5ArIyrAnXnp6T9ajwsE6NDR/xYo6GtXuOYeotYwkaHX0h+dyG9rKAThOjG6wmhVuvsCoYNQ6hAgpeJwmPoHOO6HI81mDn6XVjTuT0ECnJzpzsdBWfDPuWnowXkGz8S2lLHjaR7mQaAb+A2CKGn6x25GrxEzW0QdNRq8TDtWuk5QDiP7yKBRGSXtkObbhLYmCWjG3tDq1klMBjErBLb8vptBuHaP0ChEqj2EKz5Plp5spY2iP+CuyPvIUr13r5QORXDdmUQKL23z8Z90wYTxcfHRV2W6RV7lUEsgaq5X+UugaZFdum7CE9Pw08YYiS+6xDnCWV6QXVOMp1aerOq9UDL+n2B4cutGTWB4j0Y8z6DXuIQJYfj6Yj3plJ4nievsYSDLNLuy3zd3XZZhqL+wDI9RH+4XCAlKDW8vUTJh3R7m3Wth8g9wLSXZbIu1p9se8pYP1WbQYGb73xZ9ETWa3YuF3qRUfDYXaPpNQweooN6osJdBoJHiIpW2W40NxoGg+imPpW/qMsy3ShYUqvBILoJ1s2hr8Ffe0/jZV8vy6Qb2Hemuw23ulaDQXST9RHNWl/qZd1NvCyT1e1NcnjsnFEVzHpPdH3k9PaW/8ez97N+Fhb/A9N4WR0GVKQsAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{K}{1 + \\frac{\\left(K - p_{0}\\right) e^{- r t}}{p_{0}}}$"
      ],
      "text/plain": [
       "        K         \n",
       "──────────────────\n",
       "              -r⋅t\n",
       "    (K - p₀)⋅ℯ    \n",
       "1 + ──────────────\n",
       "          p₀      "
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "logistic = K / (1 + A * exp(-r*t))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To see whether two expressions are equivalent, we can check whether their difference simplifies to 0."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAOCAYAAAAWo42rAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAzklEQVQoFW1SiRGCMBAkGQtgtAPswKcCKYEa7MESLMWhBGkBOtAOEDuA3XDL3Cg3c9lkby+bEMI4jpkihHDHvEd+kXvkA/UOmGUUmrjFsnLrHOsXskh1E11BDBIJwdGh9cIniFoCIbgKybPlEQOjnOFv5FkZZcQFeBbGZ4bVseCOWyup2yuXZlmzqJ29UPMdhUuXWIdy6yNuKEuRTre4vGXdoLpmreZGwhrCk9/K5nzGLrm6j8vn+n3CAdyBmo11Eo7IG75rYdwZeIEo/RQTNRRqzYwqZmYAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 0$"
      ],
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(particular - logistic)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This test only works one way: if SymPy says the difference reduces to 0, the expressions are definitely equivalent (and not just numerically close).\n",
    "\n",
    "But if SymPy can't find a way to simplify the result to 0, that doesn't necessarily mean there isn't one.  Testing whether two expressions are equivalent is a surprisingly hard problem; in fact, there is no algorithm that can solve it in general."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Exercises\n",
    "\n",
    "**Exercise:** Solve the quadratic growth equation using the alternative parameterization\n",
    "\n",
    "$\\frac{df(t)}{dt} = \\alpha f(t) + \\beta f^2(t) $"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Solution\n",
    "\n",
    "alpha, beta = symbols('alpha beta')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANS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Ru3AdAKWEiVjkWcdpi8rfVX9yNWzLmXZ1n5uFeWG1N5lh5Wra6OQ/qBeVhkdgocGcVointsrGt/rvyc4rX47nLD7U3LMI7CxbarDz6sVH8prTBOsXjcDSYqb14EVutuXxfv6s81odxZ2PjliLhhfABp2KYglWRic/wvBaRv72ccandCFnz0qVAdO0RLcLozoFC2tinymERqnfQxvK6Sjr14agwU3tRrq3OuejrHKynYtWqS/wWkb+qWygt5hbEO8Ufisy0o4PouWISTsOxXOF9DA8Eq7S4bZX/UwST2tpiuK/8I8cMNzzrSewCv5lYtZq0jPy1tJh8Bf4Z3CJQWlHDfR7+MpZk1G2JuC0qQ9lJ1mvbuuJ6r/Jd7QfP1WGmPk+2eHOxao2zH4dZ8td0C1UJVgflYsu7o9c3boCS/k+L35XH4rT6g8iYPn1XWZRytCtJeegVJwGS1nuV32r76jBTn5Gvwc301jjMxWoE/9ny19zQkPnFRGK1ehsMSsf1uqf00s6esucF1cEGBvfymu6GaBFMDm2Lu0rzWnMcpQ2z5cZpLpZjlIudt48SWu7BdUEV48Jwb27btVHHy14MgeuIwFncKa+pKMtGke1QFqmcw7jDX+VjwrkjhkUh1n72oWwLhsB6Eegsl1ccd/M4uFZKYw2DQv2qNBTOBaWz3uI3Sc1zK1/EHobA6hBwW/FSFhZvKNbY/3ihdw1pdahZhw2BEQg45RIdmxYo2Nj/eAFrdtXXi9QEC4bA4SIQlGvw8whvzVhX4Rp2oZTeEdiLIWAIOAROvbJgtdJ7eFgnDrJSC8X9r16650GyBUPAEPAIBMvF52WCyoW+ncJJeeI/1dtbb5EnOiycBUPAEIgQOPW7gFinTkGkMBzIsgUfDmTj/3gBKzfmZx8is2AIrBcBtxXv3bp/BEOwXijbRpGNDtL4r1qdeyhalJDbGewu4h42b09AZ8EQWBsC/wKsbtqcux8MwQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{d}{d t} f{\\left(t \\right)} = \\alpha f{\\left(t \\right)} + \\beta f^{2}{\\left(t \\right)}$"
      ],
      "text/plain": [
       "d                      2   \n",
       "──(f(t)) = α⋅f(t) + β⋅f (t)\n",
       "dt                         "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "eq3 = Eq(diff(f(t), t), alpha*f(t) + beta*f(t)**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANIAAAA5CAYAAABDGnUDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAANVElEQVR4Ae2djXUUNxDHsR8FgKkg0AE4HSQdJFAB0AE8KuCFDkgqcEgHQAUQOoBUALgD8v/JkqyP0e7ex97t2Zr31rs7Go1GoxnNSLveO/rx48eNDl0DqQaOjo7uyi6+pLilXUvG+5Lx01LkOl6KIF2OZWhABvpHy4lU9kTHWx1vdLzW8QdS6/xMx90d9+Cu2vxlx202mzvqEampm2tXIMN8o04/Lx3JOwllZyp7FRQj/C1dgz8V/nbAz3FWW/+K72O1E6OQcK+Fazr+HHK0ePaI1NLMNcPLKO+ry18aTvRZZThYdCLUo/tznXCkj9yvA2qX+oMgGhzWSuWeC++i4iCDHRR2R9qBkg+kiReS88yQ9a1wr+Q074wyUDgRNOsCTjIGpHDVms07MinertPKSt6e2lUquVoIGRkz9lcdd+iZjI9ZvALRfVbZvbRAuGe6p/5tb7RpsbsWjXOEVnlVoUCo/lvV/bVAB944CPLiSEQ/nPa16NP0DhnPhftT571Bj0h7U/38DeMcagVDJaJgkMzeGB4bBDEl0nVrRn8q0neqixGbQFlZLn5sRkyJNCbPgBRfUk1koP2XXOuITuTpiFSmI/rynZxu7qSV3sjONSBDZiGOIaYpGSnYU5VhjGk6hiNVqZNw4P/RMQnEl3XWIx3b3k2Db+lAQSacbGOnDczWPXdHWldzy6/3UCI+LsTEWXCO3/1MnxZjkCVYzhVpfNR5KF4urfLR4pPwv0Wi5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SEDWCsiteC0RkBpHKp37zlH9tkFEy8Vy1n4kJk2SW4nVHys2EQc9mUN3fFwkPTnlW0jS6hA07QqfJ/dDlEhwurGWinOozu2jgp0SAWM+6IIpM1JtVfWc4yTj1Z2KYVKvnhObnuHYm/YIakuEQcZhlcAK2SNl0cDt4OsdfzNP1IHg+ON5tDQ7RqQJvpMxstIkzkU6yxc5Lw2Ophci2C5KHyEOf2QJ3sA85QttLPvux4zW37FlVdyQ/alIQ74pNSd1Gx1m8eNeOCDZlTTXKrxMsRwMaWyabM41t9g+rPbWbZ4z+Fttsxpqnmc51lxqQE5E9kOpXWUN3pMuRaD0/uqSYfsX6IltrTa/aKResAd6xY81Xpew9tZNmNNO49ZEUxFplKyCevC1ACrDxgn0rAnUmG2tAY8rbLaTslZ10R9pYvTYDnwa8l9K3/QDVbrBjZ9WAxpMM457G01xHd0eaUf1SPm8N8JBvrYeEM4rWWa+gAY0jW978x3Nz3dsdaQWFrkPqnYnnDn0Hbx0FLqCOxpA1L7/OUq2NgnjdkYIm+rlrYAMN/A/A5UalpDo8dwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle f{\\left(t \\right)} = \\frac{\\alpha e^{\\alpha \\left(C_{1} + t\\right)}}{\\beta \\left(1 - e^{\\alpha \\left(C_{1} + t\\right)}\\right)}$"
      ],
      "text/plain": [
       "             α⋅(C₁ + t)   \n",
       "          α⋅ℯ             \n",
       "f(t) = ───────────────────\n",
       "         ⎛     α⋅(C₁ + t)⎞\n",
       "       β⋅⎝1 - ℯ          ⎠"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "solution_eq = dsolve(eq3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJEAAAA5CAYAAAA2l8mgAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAK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1Aq9p2Z9ZAKWJscjIRangQT9obcmh6s39bQeBaQT/nlgmVKhBWzJhqjWxv63qvDQz8gHEPc1maPBeRPZpZb8me2dh4NRMikjnkizEOsvR6C0Uaj+S0gP3Jbz5uqxXXuqCBCfQskniu0O7X58bCXBPIha9zqfywYHUR7Sd0qHZUF/gOuQJKuVKeDXQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\alpha e^{\\alpha \\left(C_{1} + t\\right)}}{\\beta \\left(1 - e^{\\alpha \\left(C_{1} + t\\right)}\\right)}$"
      ],
      "text/plain": [
       "      α⋅(C₁ + t)   \n",
       "   α⋅ℯ             \n",
       "───────────────────\n",
       "  ⎛     α⋅(C₁ + t)⎞\n",
       "β⋅⎝1 - ℯ          ⎠"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "general = solution_eq.rhs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG4AAAA0CAYAAABrTg1qAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAHKUlEQVR4Ae2ci5HUOBBAd7cIANgIbskACAEy4BPBHRlAbQQUZAAXwRVkABcBnwzgIgA2A+49lWRk2fJ6YGY8Nu4qraxuqdXqVreksbzH379/P1oyHB8f/8X47pMuSF/NGfMT8I95fs3zZ/LZwfFSDYdhzrDGK9I/jPF5sgz4qxF/G/y1hJ9bfmVuAo+RNxrtE3XvYpy3eRvKF9A16KxhkYbDIm9Iz0ujZZZ6z7OeN1tYXKjEm1y7npGu6V19lonh8qhGr7SR5xfSqXTaPjGfDBBAIRaTUKQh8s2mY6KN4fNqX7vI806ixbqPLQPPEn6f+RJDpZuS12p0DOB9N6n3kHSnrz70F+A/Y5R8rTQUP4L2kdznvcPJ3nvcfYeD23vDJMkjQgAM8pFk2POo0AcPQGq8HOzDCX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66CpxPgW47reBwVOoC1A1MIrWveZUXqBY+kg5a3lfVmVh4cC2Pe5OufB4xd4+Ugf/VW/fIHfertXslPG8WjKzmHSNAtZZTuyxsqtPgfkUHepHx27cq/IyvpB1dW8Qh1TvoShWt9RAJuzNc/gxM68jWzr3IJ8tsG8ZfxUA7/e0TQb+lxbkhkLLMLkoN4T7oeE9kgeOWuuYE1WPMAiHGiKq/fKrjmeKPMMOdkDQDOZ9chQ1oDGpxk3dKDmjo9D+o2RCVp8iB76DP9XMSyxT5wCUpX89seByF936zRmhkAQxu5xt0iDYFCafSDh6gkx/QnSgvhMOIcd8sY0G9A87sC66dJrYc+VeHkY0GP8X+sJOO5U7WcJsE76LU7ovaroQO0QiWYFC4iucmcKZ0dT0P98aBnbjKQHy0HnhwY5H8HqvSRNIhy12Cjj0hUcI3RWDw8nCCNN6d24Du4RMvytBYGVGM4lOPCV1ufnCFbN0gm1OAjA7Pvy7x9kEcP0fXY/yy01Qu16NFdpbpUZzv7+qcxHJ34c05tVrl21YwKqYGWOzfYw30IIXKb4qFDvdzU3MDeEn+jWSPvScbUWdIBZpAzR1rNqHkbGdvBHKBRQiksYw4H4hI/cbkV9XLDfUXgcuek2/uFqGeM6kCzATnTxoQ016ypwQ1Ia7IyfjcJ4msbhCllVq9N1AuvdRDWARjm3G56BHCTckoSRu+cIh+31vLoQFSKHml/Gk9De9zwt7itrjXwvBSQR89SVo8EAaaQI/U9lCOrMjYbrmQ4f9IZEwqHeAcaHXh0cL0c46GX8lsrNOc9J3fjEHmo3JaOPDZsZRJsS6AF8DlnDK2zZTJc7fy28ZhjqPGXBhfTFX5RA+jRJcUfn1u71BMIrjfNoveL/aTm/kLQmiGJsOYba8Bfa9RnC3Z25yR6nDNl75uO1ghnXECH7vJ7r4z8D/+2IipJXPagAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\alpha e^{C_{1} \\alpha}}{\\beta \\left(1 - e^{C_{1} \\alpha}\\right)}$"
      ],
      "text/plain": [
       "      C₁⋅α   \n",
       "   α⋅ℯ       \n",
       "─────────────\n",
       "  ⎛     C₁⋅α⎞\n",
       "β⋅⎝1 - ℯ    ⎠"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "at_0 = general.subs(t, 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG8AAAA8CAYAAABo3+Q5AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAI4ElEQVR4Ae2ciXEUOxCGscsBcESAyYAjAiADjgiADKCIgIIMgAg4MjAZ2M8ZABEAzoD3f0ItNJek2ZnZ1S6rKnlGUk+rb53rg9+/f1+qPR0cHDyFRtH6rnZaV6VPPF7Wt+/F48NSHEelgJuCE1PP1fdjMXVrUzSso1/xdyFe3yr/V8rrgQDXQdtKfYiRe/rwk/J1mFsJyZZ95I31jvjNemC1yhMThJHvynfFyPmW6WASuXifELwV38lhombl4XGMc1kLXEVS3sL59IYyoSopqFX6WPUb0XYMTcrJiFOl8kT8TU/8DQn126pCGPpO+F+r7ZVwu1Cs8i+Vk4IawrVUvWjKGm+tysPqvi3hdRLKA+E+j42iUuWZAV8xI2sbymG7YtNlCZKQAeEvFqKFyUDwZq/M4IUL9TkarWhknCe7ZVIfguo8T8J8K0Jvi/jZlwaRYRAuCZ0flO+rr/t6hiQ4BEb/RAASk6c7yih5bZMnT8dr9XkFIjpJDUwKqskikPHn+RI0CS8h8zjGrTJKfNCqQ3ksU1hH3aSNp/JXg9M7CuVbYHletra5nsJJFKLze304Ve+IYnDEytDyxhSp/o1YJ7C5aRH+jlFQp8y03PHtaUAx1H9q1asY4E7U7hTGU/nE2uZ8Ci/G3KuXI3V0Lvd8IgDWVAhvkwlrR4hrC03qjqXCBf2S1LcbDyUTwuSpq/zzB88LcHontLsyT8HfjmDnfP0iZE4ubaSH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7mlE+q4SshY2KfcFvh2FHdCeX4c4/JO6poE7acDyt0ObbWo3AnlRQrp/G474vdCcFs/SYn4ubQTyvMMceOq8ytXeSUTFBKeZz8E4XXr064tFRjTSMED5W3uGp2f0DD2/VDdTlzi/R96Bkxd6LzjMAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\log{\\left(\\frac{\\beta p_{0}}{\\alpha + \\beta p_{0}} \\right)}}{\\alpha}$"
      ],
      "text/plain": [
       "   ⎛  β⋅p₀  ⎞\n",
       "log⎜────────⎟\n",
       "   ⎝α + β⋅p₀⎠\n",
       "─────────────\n",
       "      α      "
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "solutions = solve(Eq(at_0, p_0), C1)\n",
    "value_of_C1 = solutions[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJ4AAAAyCAYAAACtW2LuAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAIfElEQVR4Ae2dj3XbNhDGKz8P4OdMUHeDxJ2gyQaOPUHqDZyXCfySDZJM0DgbxJ3AdjdINqijDdzvB+FQEIQoyZZAkcK9B5M4/DscPt4BFAhPHh4efqm0/RqYTCZ3kvKNxuuf7Zd2sYSTCrzFSuo7h0B3IBl+aqwmfcuyrvb31lVRrWejGnip2n9stIXClVeLV1jhcXOyZO8V/1fhGXxZtLdcjZR+pHt4AG+qcKvwcQzutgJPI9kHCVTf1e65QHRN+4pf6XKj+AcAGYNQceZ3l+J9Je8YaH8MnRhaHwSkj5L5h4HOy/9N13OlsXjgPqbnioxiUWGdqnM800TZ66maA3wxMYfDtb6OASkgArqpeKOa41XgxUNf7p5VamrB7sWD35jnKc78ztzxgYAIOAdPo3S1GhybtDNAvylcxVbERk35GNRXCliVcwUGHh70uwLvzZjUr0Sql3reKbBwgJ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Pb3rdR6sauJUPvKFcCdIAM+BYqGPdAxwmw/ZhNeeZpK4SkBlIug7jMbCm1o14w62rjdEdxtO7XqXUIguEx7YjEGSX+131UUbhe1ce0sijEN67eR4JjQXJonr6Specj15cqGyvejVXKzlGRVi8dH6X6yCvkcIrB1kBBnJIZ6LQx9xv17m+roO3Nr3ur0OaDdcx7z1TtlmBB1fJfC59f9fKL0uFC71QwEJCWLoAxBlre/9K1tY0YwVp+9VrX25imXalRJ6wxnu2rnLKi8XCfeIu7xSe9Fa/q60hp0kvvev1P6Xt8EUI6MjrAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\alpha p_{0} e^{\\alpha t}}{\\alpha - \\beta p_{0} e^{\\alpha t} + \\beta p_{0}}$"
      ],
      "text/plain": [
       "           α⋅t      \n",
       "     α⋅p₀⋅ℯ         \n",
       "────────────────────\n",
       "          α⋅t       \n",
       "α - β⋅p₀⋅ℯ    + β⋅p₀"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "particular = general.subs(C1, value_of_C1)\n",
    "particular.simplify()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise:**  Use [WolframAlpha](https://www.wolframalpha.com/) to solve the quadratic growth model, using either or both forms of parameterization:\n",
    "\n",
    "    df(t) / dt = alpha f(t) + beta f(t)^2\n",
    "\n",
    "or\n",
    "\n",
    "    df(t) / dt = r f(t) (1 - f(t)/K)\n",
    "\n",
    "Find the general solution and also the particular solution where `f(0) = p_0`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
